/**
 * @file 文章管理-发布文章页面
 * @author wangshaozhi(wangshaozhi@baidu.com)
 */

import {observer} from "mobx-react";
import {Redirect, Route, Switch} from "react-router-dom";
import {useCallback} from "react";

// store
import {MainStore} from "../../../store/mainStore";

// component
import {AddArticle} from "./AddArticle";
import {PublishArticle} from "./PublishArticle";

interface IProps {
    store: MainStore;
}
export const ArticleManagement: React.FC<IProps> = observer(({
    store
}) => {
    const renderAddArticleComponent = useCallback(() => (
        <AddArticle store={store} />
    ), [store]);

    const renderPublishArticleComponent = useCallback(() => (
        <PublishArticle store={store} />
    ), [store])

    return (
        <Switch>
            <Route path="/article/add" component={renderAddArticleComponent} />
            <Route path="/article/publish" component={renderPublishArticleComponent} />
            <Redirect to="/article/add" />
        </Switch>
    );
})